﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ElectronicJournal
{
    public partial class About : System.Web.UI.Page
    {
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {
                //перенаправление авторизованного пользователя на страницу, соответствующую его роли
                if (System.Web.HttpContext.Current.User.IsInRole("Administrator"))
                {
                    MasterPageFile = "~/Admin/AdminSite.Master";
                }
                else if (System.Web.HttpContext.Current.User.IsInRole("Author"))
                {
                    MasterPageFile = "~/Account/AuthorAccount/AuthorSite.Master";
                }
                else if (System.Web.HttpContext.Current.User.IsInRole("Editor"))
                {
                    MasterPageFile = "~/Account/EditorAccount/EditorSite.Master";
                }
                else if (System.Web.HttpContext.Current.User.IsInRole("Reviewer"))
                {
                    MasterPageFile = "~/Account/ReviewerAccount/ReviewerSite.Master";
                }
            }
            else
            {
                MasterPageFile = "~/Site.Master";
            }
        }
    }
}
